package com.gk.controller;

import com.eight.pojo.TbUserCoupon;
import com.gk.service.TbUserCouponService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: GK
 * @date: 2023/3/7 16:43
 * @version:No1.0
 */
@RestController
@RequestMapping("/customer/tbUserCoupon/")
public class TbUserCouponController {


    /**
     * 用户和优惠卷的
     */
    @Resource
    private TbUserCouponService tbUserCouponService;

    /**
     * 根据用户账号和优惠卷id删除用户优惠卷
     * @param username 账号
     * @param couponId 优惠卷id
     * @return 1
     */
    @PostMapping("deleteUserCon/{username}/{couponId}")
    public int deleteUserCon(@PathVariable String  username,@PathVariable Integer couponId){
        return tbUserCouponService.deleteUserCon(username,couponId);
    }


    /**
     * 根据账号查询账号所拥有的优惠卷
     * @param username 账号
     * @return 响应前端
     */
    @GetMapping("selectAllUser/{username}")
    public List<TbUserCoupon> selectAllUser(@PathVariable String username){
        return  tbUserCouponService.selectAllUser(username);
    }
}


